#pragma warning(disable : 4819)
#pragma once
#include "Scene.h"
#include <list>
#include <memory>
#include <array>
#include "Object.h"

class Enemy;
class Player;
class Bullet;
class Animation;

class GameScene : public Scene
{
public:
    GameScene ();
    ~GameScene();
    void Init() override;
    void InitData(std::any data) override;
    void HandleEvent(SDL_Event* event) override;
    UpDateResult Update(float deltaTime) override;
    void Render() override;
    inline std::list<std::shared_ptr<Tank>>& GetTanks() { return tanks_; }
    inline std::list<std::shared_ptr<Bullet>>& GetBullets() { return bullets_; }
    Terrain* GetTerrain(int x, int y);
    inline std::shared_ptr<Player>& GetPlayer() { return player_; }

    inline void AddAnimation(std::shared_ptr<Animation> animetion) { animations_.push_back(animetion); }

private:
    void updateBullet(float deltaTime);
    void updateTanks(float deltaTime);
    void updateAniations(float deltaTime);

    void renderTerrain();
    void renderBullet();
    void renderTanks();
    void renderAimetions();

    void generateEnemy();
    void generatePlayer();

private:
    std::array<std::array<Terrain,MAP_HEIGHT>,MAP_WIDTH> terrainMap_;  //地图
    std::shared_ptr<Player> player_;                  //玩家
    std::list<std::shared_ptr<Bullet>> bullets_;    //子弹列表
    std::list<std::shared_ptr<Tank>> tanks_;        //坦克列表
    uint8_t life_ = 3;                              //玩家生命
    uint8_t enemyNum_ = 20;                          //敌人数量
    std::list<std::shared_ptr<Animation>> animations_;  //动画列表
    int index_ = 0;
};